Other Classes

The following classes are available globally.

  • Variable is a wrapper for BehaviorSubject.

    Unlike BehaviorSubject it can’t terminate with error, and when variable is deallocated it will complete its observable sequence (asObservable).

    This concept will be deprecated from RxSwift but offical migration path hasn’t been decided yet. https://github.com/ReactiveX/RxSwift/issues/1501

    Current recommended replacement for this API is RxCocoa.BehaviorRelay because:

    • Variable isn’t a standard cross platform concept, hence it’s out of place in RxSwift target.
    • It doesn’t have a counterpart for handling events (PublishRelay). It models state only.
    • It doesn’t have a consistent naming with *Relay or other Rx concepts.
    • It has an inconsistent memory management model compared to other parts of RxSwift (completes on deinit).

    Once plans are finalized, official availability attribute will be added in one of upcoming versions.

    See more

    Declaration

    Swift

    public final class Variable<Element>